/**   
* @Title: AppServiceImpl.java 
* @Package com.nebula.upms.service.impl 
* @Description: TODO(用一句话描述该文件做什么) 
* @author zhanghui   
* @date 2016年2月3日 下午3:06:22 
* @version V1.0   
*/
package com.nebula.upms.service.biz.impl;

import java.util.List;

import com.nebula.upms.service.biz.AppService;
import com.nebula.upms.service.model.po.UpmsAppPO;
import com.nebula.upms.service.model.po.UpmsAppPOExample;
import com.nebula.upms.service.model.po.UpmsPrivilegePOExample;
import com.nebula.upms.service.support.datasource.UpmsDs;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.nebula.common.framework.BaseService;

/** 
* @ClassName: AppServiceImpl 
* @Description: TODO(这里用一句话描述这个类的作用) 
* @author zhanghui
* @date 2016年2月3日 下午3:06:22 
*  
*/
@Service("appService")
@Transactional
public class AppServiceImpl extends BaseService implements AppService {

	/*
	 * <p>Title: getUpmsAppPOListByAppSystemId</p>
	 * <p>Description: </p>
	 * @param appSystemId
	 * @return
	 * @see com.nebula.upms.service.AppService#getUpmsAppPOListByAppSystemId(java.lang.String)
	 */
	@Override
	public List<UpmsAppPO> getUpmsAppPOListByAppSystemId(String appSystemId) {
		UpmsAppPOExample example=new UpmsAppPOExample();
		example.createCriteria().andAppSystemIdEqualTo(appSystemId);
		example.setOrderByClause("priority ASC");
		List<UpmsAppPO> list= UpmsDs.instance().mybatis().ds().mapper().selectByExample(example);
		return list;
	}

	/*
	 * <p>Title: isAppUsed</p>
	 * <p>Description: </p>
	 * @param appId
	 * @return
	 * @see com.nebula.upms.service.AppService#isAppUsed(java.lang.String)
	 */
	@Override
	public boolean isAppUsed(String appId) {
		UpmsPrivilegePOExample example=new UpmsPrivilegePOExample();
		example.createCriteria().andAppIdEqualTo(appId);
		int count=(int)UpmsDs.instance().mybatis().ds().mapper().countByExample(example);
		if(count>0){
			return true;
		}
		return false;
	}

	/*
	 * <p>Title: removeApp</p>
	 * <p>Description: </p>
	 * @param appId
	 * @return
	 * @see com.nebula.upms.service.AppService#removeApp(java.lang.String)
	 */
	@Override
	public int removeApp(String appId) {
		int num=UpmsDs.instance().mybatis().ds().mapper().deleteByPrimaryKey(UpmsAppPO.class, appId);
		return num;
	}

}
